<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="login">
    <h1>Login</h1>
    <form method="get" >
        <input type="text" id="username" required="required" placeholder="用户名" name="u"></input></br></br>
        <input type="password" id="password" required="required" placeholder="密码" name="p"></input></br></br>
        <input type="text" id="code" required="required" placeholder="验证码" name="p"></input><span id="uSpan"></span><br><br>
        <button id="but" type="submit">登录</button>
    </form>
</div>
<script src="js/jquery-3.3.1.min.js"></script>
<script >
    $(document).ready(function () {
        $.ajax({

            url: "system/users/verification",
            async: true,
            type: "get",
            dataType: "json",
            success: function (data) {
                $("#uSpan").html(data);
            },
            error:function () {
                alert("操作失败...");
            }
        });


       /* $.get(
            //请求的资源路径
            "system/users/verification",

            //回调函数
            function (data) {
                //将响应的数据显示到span标签
                $("#uSpan").html(data);
            },
            //响应数据形式
            "json"
        );*/
    });

    $("#but").click(function(){

            var  obj = {
                "username":$("#username").val(),
                "password":$("#password").val(),
                "code":$("#code").val()
            };
        alert(JSON.stringify(obj),);
        $.ajax({
            url: "system/users/login",
            contentType:"application/json;charset=UTF-8",
            async: false,
            type: "post",
            dataType: "text",
            data:JSON.stringify(obj),
            success: function (data) {
                alert(data);
            },
            error:function () {
                alert("操作失败...");
            }
        });
    });
</script>
</body>
</html>